test: enable missing feature for test build - #2820
Conversation
|
This may cause protoc to be built for tonic examples. I'm taking a deeper look. Update: Fixed by removing the gRPC GCP example from the default feature set. |
dfawley
left a comment
There was a problem hiding this comment.
I still don't understand cargo well enough, it seems....
| @@ -294,7 +294,7 @@ grpc-helloworld = ["dep:grpc", "dep:grpc-protobuf", "dep:protobuf"] | |||
| full = ["gcp", "routeguide", "reflection", "autoreload", "health", "grpc-web", | |||
There was a problem hiding this comment.
Is it OK that full doesn't include a feature? I guess it's also missing "tower" and "h2" already?
But what's the point in having "full" anyway? Should we delete it and move the things to "default" so it isn't misleading?
There was a problem hiding this comment.
I'm also not sure what the benefit of the full feature is. It was introduced in #1205 and has been the only default feature since optional dependencies were added to the examples crate. Users can already enable all features using Cargo's --all-features flag.
I've removed the full feature and set the default directly.
| ready, you can run the example like so: | ||
| ```bash | ||
| $ cargo run --bin grpc-gcp-client -- <project-id> | ||
| $ cargo run --bin grpc-gcp-client --features grpc-gcp -- <project-id> |
There was a problem hiding this comment.
This is still a required feature for the binary in the cargo.toml though? Does that actually mean you have to set it manually or else it won't run?
There was a problem hiding this comment.
Yes, after removing grpc-gcp from the default set, it must be explicitly enabled. Otherwise the build fails:
cargo run --bin grpc-gcp-client --features grpc-protobuf-build/build-plugin -- "$PROJECT"
error: target `grpc-gcp-client` in package `examples` requires the features: `grpc-gcp`
Consider enabling them by passing, e.g., `--features="grpc-gcp"`There was a problem hiding this comment.
That's kind of crazy. Maybe we should have a separate crate for each example? I think that could simplify all this dependency management stuff a lot.
But we should also still think about doing (1) from #2661 and splitting grpc examples from tonic.
Maybe we move the tonic examples either under tonic/ or rename to tonic-examples?
Add missing feature flags to fix
cargo testwhen run inside individual crate directories.CI previously missed this issue because running
cargo nextestfrom the workspace root automatically unifies workspace features.Additionally, because the
grpc-gcpexample depends onprotoc-gen-rust-grpc(unliketonicexamples), this PR removesgrpc-gcpfrom the default features socargo testworks out of the box. Note thatexamplescrate has no tests.